﻿#include "MovementInfo.h"
#include "../MirEnvir/Envir.h"

using namespace Server::MirEnvir;

namespace Server::MirDatabase
{

    MovementInfo::MovementInfo()
    {

    }

    MovementInfo::MovementInfo(BinaryReader *reader)
    {
        MapIndex = reader->ReadInt32();
        Source = new Point(reader->ReadInt32(), reader->ReadInt32());
        Destination = new Point(reader->ReadInt32(), reader->ReadInt32());

        NeedHole = reader->ReadBoolean();
        NeedMove = reader->ReadBoolean();

        if (Envir::LoadVersion < 69)
        {
            return;
        }
        ConquestIndex = reader->ReadInt32();
    }

    void MovementInfo::Save(BinaryWriter *writer)
    {
        writer->Write(MapIndex);
        writer->Write(Source->X);
        writer->Write(Source->Y);
        writer->Write(Destination->X);
        writer->Write(Destination->Y);
        writer->Write(NeedHole);
        writer->Write(NeedMove);
        writer->Write(ConquestIndex);
    }

    std::string MovementInfo::ToString()
    {
        return StringHelper::formatSimple("{0} -> Map :{1} - {2}", Source, MapIndex, Destination);
    }
}
